using System;
using System.Collections.Generic;
using System.Text;
using Dida.Test;
using System.Runtime.InteropServices;
using Microsoft.VisualBasic;
using Dida.Test.ParamEditor2D;

namespace TestFrameworkDev
{
	class Program
	{
		static void Init()
		{
			Gtk.Application.Init();
			Dida.Geometry.Init();

			Gtk.Application.Init();
		}

		static void Free()
		{
			Dida.Geometry.Free();
		}

		static void Main(string[] args)
		{
			try
			{
				Gtk.Application.Init();

				/*Gtk.Window wnd = new Gtk.Window("Laaa");
				ParamEditor2DView space2DEditor = new ParamEditor2DView();
				space2DEditor.Model.ControlPoints.Add(new ControlPoint2D(new Dida.Vector2D(200,30)));
				wnd.Add(space2DEditor);
				wnd.ShowAll();
				wnd.Destroyed += 
					delegate(object o, EventArgs a)
					{
						Gtk.Application.Quit();
					};
				Gtk.Application.Run();*/

				Init();

				Dida.ParsersRegister r = new Dida.ParsersRegister();
				r.ScanType(typeof(Dida.Vector3D));
				
				TestProject file = new TestProject("TestTest/TestTest.xml");

				ProgressDlg dlg = new ProgressDlg(file);
				dlg.ShowAll();
				dlg.Run(file);

				/*XmlReportWriter reportWriter = new XmlReportWriter();
				reportWriter.Begin();
				ParametricTestSettings settings = new ParametricTestSettings();
				file.RunAll(reportWriter, settings);
				reportWriter.End();*/

				Free();
			}
			catch (Exception err)
			{
				Free();

				Gtk.MessageDialog msgBox = new Gtk.MessageDialog(null,
					Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
					err.Message);
				msgBox.Title = "An error occured";
				msgBox.Run();

				Console.WriteLine(err.Message);
			}
		}
	}
}
